package com.example.controller;

import com.example.dto.RegistrationDTO;
import com.example.pojo.Response;
import com.example.service.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Registration")
public class RegistrationController {
    @Autowired
    private RegistrationService registrationService;

    @PostMapping("/add")
    public Response<String> addRegistration(@RequestBody RegistrationDTO registration) {
        try {
            registrationService.saveRegistration(registration);
            return Response.success("报名成功");
        } catch (Exception e) {
            return Response.fail("报名失败：" + e.getMessage());
        }
    }
}
